from wtforms_tornado import Form

from wtforms.fields import StringField, TextAreaField
from wtforms.validators import DataRequired, Length, Email


class MessageForm(Form):
    name = StringField("姓名", validators=[
        DataRequired(message="姓名不能为空"),
        Length(max=5, min=2, message="姓名长度为2-5之间")
    ])
    email = StringField("邮箱", validators=[
        Email(message="邮箱不合法"),
        DataRequired(message="请填写邮箱地址")
    ])
    address = StringField("地址", validators=[
        DataRequired(message="请填写地址")
    ])
    message = TextAreaField("留言", validators=[
        DataRequired(message="请填写留言")
    ])
